/************************************************************************
 * SMLib/Examples - Automata Identification Engine
 * Copyright (C) 2012-2013 Ali Khalili (khalili_DOT_ir_@SIGN_gmail_DOT_com)
 * **********************************************************************
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License (LGPL) published 
 * by the Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version. This program is distributed without any
 * warranty. See the GNU Lesser General Public License for more details. 
 * ***********************************************************************
 * File         :     
 * Description  :     
 * Change log   :     	-Date:  Change
 ************************************************************************/
﻿using System;
using System.Collections.Generic;
using SMLib.Automata.Base;
using SMLib.Automata.Moore;
//using Visualization;

namespace LearningApp.Examples
{
    public class MooreExample
    {
        /// <summary>
        /// An example on how to build and visualize a Moore machine
        /// </summary>
        public static void Execute()
        {
            Alphabet inputAlph = new Alphabet();
            inputAlph.AddSymbol(new StringSymbol("0"));
            inputAlph.AddSymbol(new StringSymbol("1"));

            Alphabet outputAlph = new Alphabet();
            outputAlph.AddSymbol(new StringSymbol("T"));
            outputAlph.AddSymbol(new StringSymbol("F"));

            MooreConstructor cons = new MooreConstructor(inputAlph, outputAlph);
            cons.AddState("q0", outputAlph[0]);
            cons.AddState("q1", outputAlph[1]);
            cons.AddState("q2", outputAlph[1]);

            cons.AddTransition(cons.State(0), inputAlph[0], cons.State(0));
            cons.AddTransition(cons.State(0), inputAlph[1], cons.State(1));

            cons.AddTransition(cons.State(1), inputAlph[0], cons.State(1));
            cons.AddTransition(cons.State(1), inputAlph[1], cons.State(2));

            cons.AddTransition(cons.State(2), inputAlph[0], cons.State(2));
            cons.AddTransition(cons.State(2), inputAlph[1], cons.State(0));

            //AutomataVisualizer.Visualize<MooreMachine.Moore_State, MooreMachine.Moore_Transition>(cons.Machine);
			//SMLib.Interoperability.DOT.DotHelper.WriteToDot("MooreExample.dot",cons);
        }
    }
}
